<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>07_v-bind细节</title>
    <style>
        .active {
            color: pink;
        }
        
        .line {
            color: green;
        }
    </style>
</head>

<body>
    <div id="app">
        <h2 class="active">传统css样式加载:{{message}}</h2>
        <h2 v-bind:class="cssName">vue样式加载:{{message}}</h2>

        <!-- <h2 v-bind:class="{key1:value1,key2:value2}">{{message}}</h2>
        <h2 v-bind:class="{类名1:true,类名2:boolean}">{{message}}</h2> -->

        <h2 v-bind:class="{active:isActive,line:isLine}">{{message}}</h2>
        <!-- 需求:点击按钮实现类名的切换 -->
        <button v-on:click="changeCssName()">改变样式</button>

        <h2 class="title" :class="[classA,classB]">{{message}}</h2>
        <h2 class="title" :class="getClasses()">{{message}}</h2>
    </div>
</body>
<script src="../vue.js"></script>
<script>
    const vm = new Vue({
        el: '#app',
        data: {
            message: '你好啊',
            cssName: 'active',
            isActive: true,
            isLine: false,
            classA: 'aaaa',
            classB: 'bbbb'
        },
        methods: {
            changeCssName() {
                this.isActive = !this.isActive
                this.isLine = !this.isLine

                // if (this.isActive) {
                //     this.isActive = false
                //     this.isLine = true
                // } else {
                //     this.isActive = true
                //     this.isLine = false
                // }

            },
            getClasses() {
                return [this.classA, this.classB]
            }
        }
    })
</script>

</html>